<template>
  <div class="box">
    <div class="login-form">
      <el-form
          label-position="left"
          label-width="80px"
        :model="loginForm">
        <el-form-item label="username">
          <el-input v-model="loginForm.name"/>
        </el-form-item>
        <el-form-item label="password">
          <el-input show-password v-model="loginForm.password"/>
        </el-form-item>
        <el-form-item>
          <el-button @click="login" style="float: right">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import {Login} from "@/http/api";

export default {
    name: "login",
    data(){
      return{
        loginForm:{
          name:"",
          password:"",
        }
      }
  },
  methods:{
      login(){
        Login(this.loginForm).then(res=>{
          let data = res.data;
          if (data.code!=200){
            alert(data.msg)
          }else {
            this.$router.push("home")
          }
        })
      }
  }
}
</script>

<style scoped>

.login-form{
  width: 20vw;
  height: 10vw;
  margin: 60px auto 0 auto;
  padding: 40px;
  box-shadow: 0 0 1px gainsboro;
}
</style>